<template>
  <div class="address-selector">
    <el-table
      :data="addressList"
      :header-cell-style="{background:'#fafafa',color:'#565551'}"
      @row-click="handleSelectRow"
      max-height="400"
      border
    >
      <el-table-column
        prop="wmId"
        label="ID"
        width="60">
      </el-table-column>
      <el-table-column
        show-overflow-tooltip
        prop="wmName"
        label="名称"
        width="140">
      </el-table-column>
      <el-table-column
        show-overflow-tooltip
        prop="wmAddress"
        label="地址"
        width="170">
      </el-table-column>
      <el-table-column
        show-overflow-tooltip
        prop="wmCompanyName"
        label="所属公司"
        width="110">
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { mapState } from "vuex";
import moment from 'moment'
export default {
  components: {
  },
  name: "",
  props: {
    searchText: {
      type: String,
      default: '',
    },
  },
  data() {
    return {
      addressList: [],
    }
  },
  computed: {
  },
  mounted() {
    //this.searchAddress()
  },
  methods: {
    close() {
      this.$emit('close',false)
    },
    save(row) {
      this.$emit('close',true,{
        storageLocationId: row.wmId,
        storageLocationName: row.wmAddress,
      })
    },
    //查询地址
    searchAddress(){
      this.addressList = [
        { wmId: '1', wmName: '汕头仓库', wmAddress: '汕头市金平区月浦南澄海路北侧1号', wmCompanyName: '汕头公司' },
        { wmId: '2', wmName: '集团领料仓库', wmAddress: '前横路169号', wmCompanyName: '集团总部' },
      ]
    },
    //选中行
    handleSelectRow(row,column){
      console.log(row,66645)
      this.save(row)
    },
  },
  watch: {
    searchText: {
      handler: function(val){
        console.log(val)
        this.searchAddress()
      },
      immediate: true,
    }
  },
};
</script>
<style lang="less" scoped>
@textColor: #1f1e1d;
@ntalkColor: #e67529;
.address-selector {
  position: absolute;
  background-color: #fff;
  top: 44px;
  left: 80px;
  padding: 4px;
  border-radius: 6px;
  box-shadow: 0px 6px 16px 0px rgba(0, 0, 0, 0.08),0px 3px 6px -4px rgba(0, 0, 0, 0.12),0px 9px 28px 8px rgba(0, 0, 0, 0.05);
  z-index: 5000;
}
</style>
